package avicit.bdp.dcs.utils;

import org.apache.commons.collections4.CollectionUtils;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 通用工具类
 */
public class CommonUtil {

    /**
     * 过滤map中value为null，修改成空字符串
     * @param list
     */
    public static void filterMapNull(List<Map<String, Object>> list){
        if (CollectionUtils.isNotEmpty(list)) {
            Object value = null;
            String key = "";
            for(Map<String, Object> map : list){
                Set<String> set = map.keySet();
                Iterator<String> it = set.iterator();
                while(it.hasNext()){
                    key = it.next();
                    value = map.get(key);
                    if(value == null){
                        map.put(key, "");
                    }
                }
            }
        }
    }

}
